let utils = {
  /**
   * 验证手机号码
   * @param phoneNum
   * @returns {boolean}
   */
  checkMobile: function checkMobile(phoneNum) {
    return /^1[3|5|7|8]\d{9}$/.test(phoneNum)
  },
  /**
   * 根据folderCode 获取资产
   * @param folderCode
   * @returns {Array}
   */
  getIps4kContents(folderCode) {
    let contents = []
    let url = "http://ips-4k.hzdtv.tv/dataquery/folderContents" +
      "?folderCode=" + folderCode +
      "&fields=viewpoints&pageItems=20&cImageMode=384,214,JPG&segmentIndex=1&pageIndex=1";
    this.hs.ajax.post("http://125.210.113.145/WSL/Core/CrossDomain.ashx",
      "url=" + encodeURIComponent(url) +
      "&data=&method=get&type=default",
      obj => {
        obj = JSON.parse(obj);
        // console.log(obj);
        if (obj.contents.length > 0) {
          contents = obj.contents
        }
      }, 0, function (msg) {
      }, 3000);
    return contents
  },
  /**
   * 带鉴权订购播放视频
   * @param folderCode
   * @param contentId
   * @param contentType
   */
  goPlay(folderCode, contentId, contentType) {
    // this.$store.commit("setAppShow", false);
    let _this = this
    let url = "http://ips-4k.hzdtv.tv/dataquery/gotoAuthPlay" +
      "?folderCode=" + folderCode +
      "&contentId=" + contentId +
      "&contentType=" + contentType;
    this.hs.ajax.get(url,
      _responseText => {
        let res = JSON.parse(_responseText);
        //console.log(res);
        if (res.result == "0" || res.result == 0) {
          if (res.authResult == 0) {
            let url = "http://ips-4k.hzdtv.tv/dataquery/contentPlayUrl" +
              "?folderCode=" + folderCode +
              "&contentId=" + contentId +
              "&contentType=" + contentType +
              "&playUrlType=rtsp";
            this.hs.ajax.get(url,
              _responseText => {
                let res = JSON.parse(_responseText);
                setTimeout(() => {
                  _this.bridge.gotoApplication2play(res.playUrl);
                }, 100)
              }, 0, 3000);
          } else {
            _this.bridge.gotoApplication2order({
              ppvId: res.ppvId,
              columnAlias: this.folderCode
            });
          }
        }
      }, 0, 3000);
  },
}

export default utils
